package cn.hcbycloud.common.async.config;

import cn.hcbycloud.common.async.service.AsyncTaskManagerService;
import cn.hcbycloud.common.async.service.IAsyncService;
import cn.hcbycloud.common.async.service.impl.ThreadPoolServiceImpl;
import cn.hcbycloud.common.async.service.pool.IThreadPoolService;
import cn.hcbycloud.common.redis.utils.RedisOperator;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author gaoh
 * @desc 异步任务配置类
 * @date 2022年02月07日 下午 12:20
 */
@Slf4j
@Configuration
@AllArgsConstructor
public class AsyncTaskConfig {

    /**
     * 将异步任务管理器注入容器
     * @return
     */
    @Bean
    public AsyncTaskManagerService getAsyncTaskManagerService() {
        return new AsyncTaskManagerService();
    }

    /**
     * 线程池配置默认实现 ，可以在项目中自定义实现BaseThreadPoolService抽象类
     * @return
     */
    @Bean
    @ConditionalOnMissingBean(IThreadPoolService.class)
    public IThreadPoolService getIThreadPoolService() {
        return new ThreadPoolServiceImpl();
    }
}